home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / boot / scsiDiskBoot / RCS / main.c,v < prev    next >
Encoding:
Text File  |  1989-06-08  |  5.3 KB  |  301 lines

  1. head     1.6;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    mendel:1.6; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.6
  10. date     89.01.06.08.12.02;  author brent;  state Exp;
  11. branches ;
  12. next     1.5;
  13.  
  14. 1.5
  15. date     87.05.11.11.06.57;  author brent;  state Exp;
  16. branches ;
  17. next     1.4;
  18.  
  19. 1.4
  20. date     86.07.24.11.25.46;  author brent;  state Exp;
  21. branches ;
  22. next     1.3;
  23.  
  24. 1.3
  25. date     86.07.23.13.33.11;  author brent;  state Exp;
  26. branches ;
  27. next     1.2;
  28.  
  29. 1.2
  30. date     86.07.21.09.31.17;  author brent;  state Exp;
  31. branches ;
  32. next     1.1;
  33.  
  34. 1.1
  35. date     86.07.16.13.23.46;  author brent;  state Exp;
  36. branches ;
  37. next     ;
  38.  
  39.  
  40. desc
  41. @main boot program
  42. @
  43.  
  44.  
  45. 1.6
  46. log
  47. @Mon_Printf => Mach_MonPrintf
  48. @
  49. text
  50. @/* 
  51.  * main.c --
  52.  *
  53.  *    The main program for booting.
  54.  *
  55.  * Copyright 1986 Regents of the University of California
  56.  * All rights reserved.
  57.  */
  58.  
  59. #ifndef lint
  60. static char rcsid[] = "$Header: main.c,v 1.5 87/05/11 11:06:57 brent Exp $ SPRITE (Berkeley)";
  61. #endif not lint
  62.  
  63.  
  64. #include "sprite.h"
  65. #include "machMon.h"
  66. #include "fs.h"
  67.  
  68. void Exit();
  69.  
  70. /*
  71.  *----------------------------------------------------------------------
  72.  *
  73.  * main --
  74.  *
  75.  *      This gets arguments from the PROM, calls other routines to open
  76.  *      and load the program to boot, and then transfers execution to that
  77.  *      new program.
  78.  *
  79.  * Results:
  80.  *    None.
  81.  *
  82.  * Side effects:
  83.  *    None.
  84.  *
  85.  *----------------------------------------------------------------------
  86.  */
  87.  
  88. main()
  89. {
  90.     ReturnStatus status;
  91.     register MachMonBootParam *paramPtr;/* Ref to boot params supplied
  92.                      * by the PROM montor */
  93.     register int index;            /* Loop index */
  94.     register int entry;            /* Entry point of boot program */
  95.     FsHandle *handlePtr;        /* Handle for boot program file */
  96.  
  97.     /*
  98.      * The Sun prom collects the boot command line arguments and
  99.      * puts makes them available throught the rom vector.
  100.      */
  101.     paramPtr = *romVectorPtr->bootParam;
  102. #ifndef NO_PRINTF
  103.     for (index=0 ; index < 8; index ++) {
  104.     if (paramPtr->argPtr[index] != (char *)0) {
  105.         Mach_MonPrintf("Arg %d: %s\n", index, paramPtr->argPtr[index]);
  106.     } else {
  107.         break;
  108.     }
  109.     }
  110.     Mach_MonPrintf("Device %s\n", paramPtr->devName);
  111.     Mach_MonPrintf("File \"%s\"\n", paramPtr->fileName);
  112. #endif
  113.  
  114.     /*
  115.      * Set up VM so the user context is the same as the kernel context.
  116.      * This simplifies the mapping routines.
  117.      */
  118.     VmSetUserContext();
  119.  
  120.     /*
  121.      * Probe the boot device.
  122.      */
  123.     Dev_Config();
  124.  
  125.     /*
  126.      * Set up for Block I/O to the boot device
  127.      */
  128. #ifndef NO_PRINTF
  129.     Sys_Printf("Boot %s(%d,%d,%d)%s\n", paramPtr->devName,
  130.              paramPtr->ctlrNum, paramPtr->unitNum,
  131.              paramPtr->partNum, paramPtr->fileName);
  132. #endif
  133.     if (paramPtr->devName[0] == 's' &&
  134.     paramPtr->devName[1] == 'd') {
  135.     Fs_AttachDisk(paramPtr->ctlrNum, paramPtr->unitNum,
  136.                      paramPtr->partNum);
  137.     } else {
  138.     Mach_MonPrintf("Can't boot \"%s\"\n", paramPtr->devName);
  139.     goto exit;
  140.     }
  141.  
  142.     /*
  143.      * Open the file to bootstrap.
  144.      */
  145.     status = Fs_Open(paramPtr->fileName, FS_READ, 0, &handlePtr);
  146.     if (status != SUCCESS) {
  147.     Mach_MonPrintf("Can't open \"%s\", <%x>\n", paramPtr->fileName, status);
  148.     goto exit;
  149.     }
  150.     entry = FileLoad(handlePtr);
  151.     if (entry != -1) {
  152. #ifndef NO_PRINTF
  153.     Mach_MonPrintf("Transfering to %x\n", entry);
  154. #endif
  155.     Boot_Transfer(entry);
  156.     }
  157. exit:
  158.     return;
  159. }
  160.  
  161. /*
  162.  * Exit is called by start.s
  163.  */
  164. void
  165. Exit()
  166. {
  167.     Mach_MonPrintf("Boot exiting\n");
  168.     /*
  169.      * Return to start.s and then the PROM monitor.
  170.      */
  171.     return;
  172. }
  173. @
  174.  
  175.  
  176. 1.5
  177. log
  178. @Complete trimmed down version.
  179. @
  180. text
  181. @d11 1
  182. a11 1
  183. static char rcsid[] = "$Header: main.c,v 1.4 86/07/24 11:25:46 brent Exp $ SPRITE (Berkeley)";
  184. d16 1
  185. a16 1
  186. #include "sunMon.h"
  187. a17 1
  188. #include "fsInt.h"
  189. d42 1
  190. a42 1
  191.     register Mon_BootParam *paramPtr;    /* Reference to boot parameters supplied
  192. d56 1
  193. a56 1
  194.         Mon_Printf("Arg %d: %s\n", index, paramPtr->argPtr[index]);
  195. d61 2
  196. a62 2
  197.     Mon_Printf("Device %s\n", paramPtr->devName);
  198.     Mon_Printf("File \"%s\"\n", paramPtr->fileName);
  199. d89 1
  200. a89 1
  201.     Mon_Printf("Can't boot \"%s\"\n", paramPtr->devName);
  202. d98 1
  203. a98 1
  204.     Mon_Printf("Can't open \"%s\", <%x>\n", paramPtr->fileName, status);
  205. d104 1
  206. a104 1
  207.     Mon_Printf("Transfering to %x\n", entry);
  208. d118 1
  209. a118 1
  210.     Mon_Printf("Boot exiting\n");
  211. @
  212.  
  213.  
  214. 1.4
  215. log
  216. @more trimming
  217. @
  218. text
  219. @d11 1
  220. a11 1
  221. static char rcsid[] = "$Header: main.c,v 1.3 86/07/23 13:33:11 brent Exp $ SPRITE (Berkeley)";
  222. d85 2
  223. a86 1
  224.     if (String_Compare("sd", paramPtr->devName) == 0) {
  225. d90 1
  226. a90 1
  227.     Mon_Printf("Can't boot from \"%s\"\n", paramPtr->devName);
  228. @
  229.  
  230.  
  231. 1.3
  232. log
  233. @cosmetic fixes
  234. @
  235. text
  236. @d11 1
  237. a11 1
  238. static char rcsid[] = "$Header: main.c,v 1.2 86/07/21 09:31:17 brent Exp $ SPRITE (Berkeley)";
  239. d89 1
  240. a89 1
  241.     Mon_Printf("Can't boot from dev \"%s\"\n", paramPtr->devName);
  242. d103 1
  243. d105 1
  244. @
  245.  
  246.  
  247. 1.2
  248. log
  249. @First complete versino
  250. @
  251. text
  252. @d11 1
  253. a11 1
  254. static char rcsid[] = "$Header: main.c,v 1.1 86/07/16 13:23:46 brent Exp $ SPRITE (Berkeley)";
  255. d45 3
  256. a47 3
  257.     register int index;
  258.     register int entry;
  259.     FsHandle *handlePtr;
  260. d49 4
  261. d80 5
  262. d87 1
  263. a87 1
  264.                      paramPtr->partNum, &handlePtr);
  265. d103 1
  266. d116 1
  267. a116 1
  268.     Mon_Printf("Exit called\n");
  269. @
  270.  
  271.  
  272. 1.1
  273. log
  274. @Initial revision
  275. @
  276. text
  277. @d11 1
  278. a11 1
  279. static char rcsid[] = "$Header: proto.c,v 1.4 86/03/20 14:00:11 andrew Exp $ SPRITE (Berkeley)";
  280. d17 2
  281. a20 1
  282. void Quit();
  283. d42 1
  284. d46 2
  285. d50 1
  286. d60 1
  287. d62 5
  288. a66 2
  289.     Quit("Quitting to monitor");
  290. }
  291. d68 30
  292. a97 6
  293. void
  294. Quit(msg)
  295.     char *msg;
  296. {
  297.     Mon_Printf("%s\n", msg);
  298.     Exit();
  299. d100 3
  300. @
  301.